﻿using MessagePack;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace Manon.Repository.Collections
{
    /// <summary>
    /// 数据的分页 
    /// </summary>
    /// <typeparam name="T"></typeparam> 
    [MessagePackObject(true)]
    public class PagedList<T>
    {
        /// <summary>
        /// 当前页 值
        /// </summary> 
        public int PageIndex { get; set; }
        /// <summary>
        /// 每页大小
        /// </summary> 
        public int PageSize { get; set; }
        /// <summary>
        /// 数据总数
        /// </summary> 
        public long TotalCount { get; set; }
        /// <summary>
        /// 总页数
        /// </summary> 
        public int TotalPages { get; set; }
        /// <summary>
        /// 起始页 值
        /// </summary> 
        public int IndexFrom { get; set; }
        /// <summary>
        /// 当前页数据
        /// </summary> 
        public IEnumerable<T>? Items { get; set; }

        /// <summary>
        /// 是否有上一页
        /// </summary> 
        public bool HasPreviousPage
        {
            get
            {
                return PageIndex - IndexFrom > 0;
            }
            set { }
        }
        /// <summary>
        /// 是否有下一页
        /// </summary> 
        public bool HasNextPage
        {
            get
            {
                return PageIndex - IndexFrom + 1 < TotalPages;
            }
            set { }
        }



    }

}
